<?php
/*
 * @Author: your name
 * @Date: 2020-12-17 14:50:30
 * @LastEditTime: 2020-12-17 16:53:00
 * @LastEditors: Please set LastEditors
 * @Description: 更新日志数据验证器
 * @FilePath: /special/application/adminapiv3/validate/ServerUpdateLogValidate.php
 */
namespace app\adminapiv3\validate;

use think\Validate;

class ServerUpdateLogValidate extends Validate
{
    protected $rule = [
        //资产ID
        'id|资产ID' => 'number|length:1,10',
        //主机ip
        'ip|资产IP地址' => 'regex:^\d{1,3}(\.\d{1,3}){0,3}$',
        //资产名称
        'name|资产名称' => 'length:1,25',
        // 客户端版本号
        'client_version|客户端版本号' => 'length:1,25',
        // 客户端更新状态
        'client_update_status|客户端更新状态' => 'in:2,3,4,5,6',
        /* 更新详细信息 */
        //资产ID
        'host_id|资产ID' => 'require|number|length:1,10',
        //更新前版本号
        'old_version|更新前版本号' => 'length:1,25',
        // 更新后版本号
        'new_version|更新后版本号' => 'length:1,25',
        // 更新状态
        'status|更新状态' => 'in:1,2,3,4,5',
        // 描述信息
        'desc|描述信息' => 'length:1,50',
        // 创建时间
        'ctime|创建时间' => 'date'
    ];

    protected $message = [
        'client_update_status.in' => '客户端更新状态格式错误',
        'status.in' => '客户端更新状态格式错误'
    ];

    protected $scene = [
        //主机列表
        'list' => ['id','name','ip','client_version','client_update_status'],
        //详情页
        'details' => ['host_id', 'old_version', 'new_version', 'ip', 'status', 'desc', 'ctime']
    ];
}